<?php

namespace app\controllers;

use Yii;
use yii\web\Controller;
use app\models\Phone;
use wx\frontend\Jssdk;

class PanglemeController extends Controller {
    public $layout = "sunhope";
    public function actionShare() {
        $jssdk = new Jssdk("wx3ed63b2c53d29a89", "b1c9cb16bb440bea35106887c3063205");
        $signPackage = $jssdk->GetSignPackage();
        return $this->render('share', array(
            'signPackage' => $signPackage,
        ));
    }
    public function actionSubmitPhone() {
        try {
            $phone = new Phone();
            $phone->phonenumber = intval(Yii::$app->request->get('number'));
            $phone->time = time();
            $phone->name = strval(Yii::$app->request->get('name'));
            $phone->save();
            return "ok";
        } catch (\Exception $e) {
            return "not ok";
        }
    }
    public function actionApply() {
        $jssdk = new Jssdk("wx3ed63b2c53d29a89", "b1c9cb16bb440bea35106887c3063205");
        $signPackage = $jssdk->GetSignPackage();
        $this->layout = "sunhopeok";
        return $this->render('apply', array(
            'signPackage' => $signPackage,
        ));
    }
    public function actionAftershared() {
        $this->layout = "sunhopeok";
        return $this->render('success');
    }
}
